{% extends "profile/base.html" %}

{% block title %}用户登录 - 用户资料管理系统{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-lg-5 col-md-7">
            <!-- 页面标题 -->
            <div class="text-center mb-4 fade-in">
                <h1 class="fw-bold text-primary">
                    <i class="fas fa-sign-in-alt me-2"></i>欢迎回来
                </h1>
                <p class="text-muted">登录您的账户以继续</p>
            </div>

            <!-- 登录表单卡片 -->
            <div class="card shadow-sm fade-in">
                <div class="card-header bg-gradient text-white">
                    <h4 class="mb-0 text-center">
                        <i class="fas fa-user-circle me-2"></i>用户登录
                    </h4>
                </div>
                <div class="card-body p-4">
                    <form method="POST" class="ajax-form">
                        {{ form.hidden_tag() }}
                        
                        <div class="mb-3">
                            {{ form.username.label(class="form-label fw-medium") }}
                            <div class="input-group">
                                <span class="input-group-text bg-light">
                                    <i class="fas fa-user text-muted"></i>
                                </span>
                                {{ form.username(class="form-control border-start-0", placeholder="请输入用户名或邮箱") }}
                            </div>
                            {% if form.username.errors %}
                                <div class="text-danger small mt-1">
                                    {% for error in form.username.errors %}
                                        {{ error }}
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3">
                            {{ form.password.label(class="form-label fw-medium") }}
                            <div class="input-group">
                                <span class="input-group-text bg-light">
                                    <i class="fas fa-lock text-muted"></i>
                                </span>
                                {{ form.password(class="form-control border-start-0", placeholder="请输入密码") }}
                            </div>
                            {% if form.password.errors %}
                                <div class="text-danger small mt-1">
                                    {% for error in form.password.errors %}
                                        {{ error }}
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3 form-check">
                            {{ form.remember_me(class="form-check-input") }}
                            {{ form.remember_me.label(class="form-check-label") }}
                        </div>
                        
                        <div class="d-grid mb-3">
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-sign-in-alt me-2"></i>登录
                            </button>
                        </div>
                    </form>
                    
                    <div class="text-center">
                        <p class="mb-0">还没有账号？<a href="{{ url_for('profile.register') }}" class="text-decoration-none">立即注册</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_css %}
<style>
    .bg-gradient {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    .fade-in {
        opacity: 0;
        animation: fadeIn 0.5s ease-in forwards;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }
    
    .input-group-text {
        border-right: none;
    }
    
    .border-start-0 {
        border-left: none;
    }
    
    .form-control:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    }
    
    .btn-primary {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: none;
        transition: all 0.3s ease;
    }
    
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
    }
</style>
{% endblock %}

{% block extra_js %}
<script>
    $(document).ready(function() {
        // 初始化动画
        $('.fade-in').each(function(index) {
            $(this).delay(100 * index).animate({ opacity: 1 }, 500);
        });
    });
</script>
{% endblock %}